<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>计算器</title>
</head>

<body>
    <div>
        <input type="text" id="txt1" placeholder="第一个数">
        <select id="fh">
            <option value="+">+</option>
            <option value="-">-</option>
            <option value="*">*</option>
            <option value="/">/</option>
            <option value="%">%</option>
        </select>
        <input type="text" id="txt2" placeholder="第二个数">
        <button id="btn">计算</button>
        <input type="text" id="txt3" placeholder="结果">
    </div>
    <div>
        <input type="text" id="txt4" placeholder="请输入年份">
        <button id="btn1">判断</button>
        <input type="text" id="txt5" placeholder="平年/闰年">
    </div>

    <script>
        var txt1 = document.querySelector('#txt1');
        var fh = document.querySelector('#fh');
        var txt2 = document.querySelector('#txt2');
        var btn = document.querySelector('#btn');
        var txt3 = document.querySelector('#txt3');
        var txt4 = document.querySelector('#txt4');
        var btn1 = document.querySelector('#btn1');
        var txt5 = document.querySelector('#txt5');

        btn.onclick = function () {
            var a = +txt1.value;
            var b = +txt2.value;
            var c = fh.value;
            var sum = 0;
            switch (c) {
                case '+':
                    sum = a + b;
                    break;
                case '-':
                    sum = a - b;
                    break;
                case '*':
                    sum = a * b;
                    break;
                case '/':
                    sum = a / b;
                    break;
                case '%':
                    sum = a % b;
                    break;
            }
            txt3.value = sum;
        }

        btn1.onclick = function () {
            var x = +txt4.value;
            if (x % 4 == 0 && x % 100 != 0 || x % 400 == 0)
                var y = x + '是润年';
            else
                var y = x + '是平年';
            txt5.value = y;
        }

    </script>
</body>

</html>